/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "subcontarctor_resources")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SubcontarctorResources.findAll", query = "SELECT s FROM SubcontarctorResources s"),
    @NamedQuery(name = "SubcontarctorResources.findBySubResId", query = "SELECT s FROM SubcontarctorResources s WHERE s.subResId = :subResId"),
    @NamedQuery(name = "SubcontarctorResources.findBySubResName", query = "SELECT s FROM SubcontarctorResources s WHERE s.subResName = :subResName")})
public class SubcontarctorResources implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "sub_res_id")
    private Integer subResId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "sub_res_name")
    private String subResName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "subcontResName")
    private Collection<SourceCode> sourceCodeCollection;
    @JoinColumn(name = "subcontractor", referencedColumnName = "sub_id")
    @ManyToOne(optional = false)
    private Subcontarctors subcontractor;

    public SubcontarctorResources() {
    }

    public SubcontarctorResources(Integer subResId) {
        this.subResId = subResId;
    }

    public SubcontarctorResources(Integer subResId, String subResName) {
        this.subResId = subResId;
        this.subResName = subResName;
    }

    public Integer getSubResId() {
        return subResId;
    }

    public void setSubResId(Integer subResId) {
        this.subResId = subResId;
    }

    public String getSubResName() {
        return subResName;
    }

    public void setSubResName(String subResName) {
        this.subResName = subResName;
    }

    @XmlTransient
    public Collection<SourceCode> getSourceCodeCollection() {
        return sourceCodeCollection;
    }

    public void setSourceCodeCollection(Collection<SourceCode> sourceCodeCollection) {
        this.sourceCodeCollection = sourceCodeCollection;
    }

    public Subcontarctors getSubcontractor() {
        return subcontractor;
    }

    public void setSubcontractor(Subcontarctors subcontractor) {
        this.subcontractor = subcontractor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (subResId != null ? subResId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SubcontarctorResources)) {
            return false;
        }
        SubcontarctorResources other = (SubcontarctorResources) object;
        if ((this.subResId == null && other.subResId != null) || (this.subResId != null && !this.subResId.equals(other.subResId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojos.SubcontarctorResources[ subResId=" + subResId + " ]";
    }
    
}
